<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>积分后台管理</title>
		<link rel="icon" href="img/lei_huiyuan_on.png"  size="16x16" />
	</head>
	<body>
<div id="top">
			
</div>
		<div class="body content"  id="app">
			<div id="left">

			</div>

			<div class="right">

				<div class="liebie_title style_hei_16">
					<img src="img/xiugai.png">网站配置
				</div>
				<div class="bottom">

					<div class="fenzhan">
					    <div class="fenzhan_list peizhi">
					        <p><span class="fenzhan_name">网站名称：</span><input type="text" v-model="name" placeholder="请输入"/></p>
					    </div>
					
					    <div class="shenfen_img">
					        <span class="fenzhan_name">网站LOGO：</span>
					        <div class="img_zheng">
					            <img class="ossimg" :src="logo" v-if="logo">
					        </div>
					        <div class="up_logo">
					            <input type="file" name="" id="shenfen_zheng" value="" @change="upload_zheng()"/>
					        </div>
					        <!-- <p class="style_hui_12">请上传尺寸为 （149*50） 的图片</p> -->
					    </div>
					
					    
					   
					    
					
					    
					    
					    <div class="fenzhan_list peizhi">
					         <p><span class="fenzhan_name">客服电话：</span><input type="text" v-model="dianhua" placeholder="请输入"/></p>
					    </div>
						<div class="shenfen_img">
						    <span class="fenzhan_name">客服二维码：</span>
						    <div class="img_zheng2">
						        <img class="ossimg2" :src="erweima" v-if="erweima">
						    </div>
						    <div class="up_logo">
						        <input type="file" name="" id="shenfen_ma" value="" @change="upload_ma()"/>
						    </div>
						    <!-- <p class="style_hui_12">请上传尺寸为 （149*50） 的图片</p> -->
						</div>
						<div class="fenzhan_list peizhi">
						     <p><span class="fenzhan_name">服务时间：</span><input type="text" v-model="time" placeholder="请输入"/ style="width: 300px;"></p>
						</div>
					
					   
					    
					    <button type="button" class="fenzhan_shenqing" @click="shenqing()">确认配置</button>
					</div>


				</div>
			</div>
		</div>
<script src="js/jquery-3.4.1.min.js" type="text/javascript" charset="utf-8"></script>
<script src="layer/layer.js" type="text/javascript" charset="utf-8"></script>
<script src="laydate/laydate.js" type="text/javascript" charset="utf-8"></script>
<script src="js/selectFilter.js" type="text/javascript" charset="utf-8"></script>
<script src="js/get.js" type="text/javascript" charset="utf-8"></script>
<script src="js/gong.js"></script>
<script src="js/fengzhuang.js"></script>
<script src="js/vue.js"></script>
<script>
	var app = new Vue({
	    el: '#app',
	    data:{
	        name :'',
			logo:'',
			dianhua:'',
			erweima:'',
			time:''
	    },
		mounted(){
			this.get_xq()
		},
		methods:{
			
			get_xq(){
			    $.ajaxDirect("/api/getConfig",'get',{
			    	'page':this.page,
			    	'limit':this.limit
			    },
			     (obj)=> {
			    		  if(obj.code==200&&obj.config){
			    			  
			    			  this.name=obj.config.website_name
							  this.logo=obj.config.website_logo
							  this.dianhua=obj.config.customer_service_phone
							  this.erweima=obj.config.customer_service_qrcode
							  this.time=obj.config.service_time

			    		  }
			    },
			    (err)=> {
			            //发送失败
			    })
			},
			shenqing(){
				$.ajaxDirect("/api/updateConfig",'post',{
					'website_name':this.name,
					'website_logo':this.logo,
					customer_service_phone:this.dianhua,
					customer_service_qrcode:this.erweima,
					service_time:this.time
				},
				 (obj)=> {
						  if(obj.code==200){
							  
							  layer.msg('配置成功')
				
						  }
				},
				(err)=> {
				        //发送失败
				})
			},
			upload_zheng() {
				 var that=this
				 var fileImgs=$("#shenfen_zheng")[0].files
				 
				   
				 for(var i=0; i<fileImgs.length; i++){
				 	    
						var formData = new FormData();
						formData.append("file", fileImgs[i]);
						$.ajax({
						        url: 'http://120.55.77.106:3000/api/upload',  
						        type: 'POST',  
						        data: formData,  
						        dataType: 'JSON',  
						        cache: false,  
						        processData: false,  
						        contentType: false,
						        success : function(data) {
						            if(data.code==200){
										that.logo=data.fileUrl
									}
						        },
						        error:function(){
						            alert("上传失败");
						        }
						    });
				                             
				     }
			
			},
			upload_ma() {
				 var that=this
				 var fileImgs=$("#shenfen_ma")[0].files
				 
				   
				 for(var i=0; i<fileImgs.length; i++){
				 	    
						var formData = new FormData();
						formData.append("file", fileImgs[i]);
						$.ajax({
						        url: 'http://120.55.77.106:3000/api/upload',  
						        type: 'POST',  
						        data: formData,  
						        dataType: 'JSON',  
						        cache: false,  
						        processData: false,  
						        contentType: false,
						        success : function(data) {
						            if(data.code==200){
										that.erweima=data.fileUrl
									}
						        },
						        error:function(){
						            alert("上传失败");
						        }
						    });
				                             
				     }
			
			},
	
		}
	})	
</script>

	</body>
</html>